var MsgSendLog = {
    id: "MsgSendLogTable",
    seItem: null,
    table: null,
    layerIndex: -1
};

MsgSendLog.initColumn = function () {
    return [
        {title: '', field: 'id', visible: false, align: 'center', valign: 'middle', width: '50px'},
        {title: '发送人', field: 'sender', align: 'center', valign: 'middle', sortable: true},
        {title: '门诊', field: 'outpatientName', align: 'center', valign: 'middle', sortable: true},
        {title: '患者电话', field: 'customerPhone', align: 'center', valign: 'middle', sortable: true},
        {title: '患者姓名', field: 'customerName', align: 'center', valign: 'middle', sortable: true},
        {
            title: '发送时间', field: 'sendTime', align: 'center', valign: 'middle', sortable: true,
            formatter: function (value, row, index) {
                return value.substring(0, 19);
            }
        },
        {title: '短信内容', field: 'messageContent', align: 'center', valign: 'middle', sortable: true},
        {
            title: '是否成功', field: 'isSuccess', align: 'center', valign: 'middle', sortable: true,
            formatter: function (value, row, index) {
                if (value == 1) {
                    return "发送成功";
                } else {
                    return "发送失败";
                }
            }
        },
    ];
};

MsgSendLog.formParams = function () {
    var queryData = {};
    queryData['sender'] = $("#sender").val();
    queryData['customerPhone'] = $("#customerPhone").val();
    queryData['customerName'] = $("#customerName").val();
    queryData['startTime'] = $("#startTime").val();
    queryData['endTime'] = $("#endTime").val();
    queryData['outpatientName'] = $("#outpatientName").val();
    return queryData;
};

MsgSendLog.resetSearch = function () {
    $("#sender").val("");
    $("#customerPhone").val("");
    $("#customerName").val("");
    $("#startTime").val("");
    $("#endTime").val("");
    $("#outpatientName").val("");
    MsgSendLog.search();
};

MsgSendLog.search = function () {
    MsgSendLog.table.refresh({query: MsgSendLog.formParams()});
};
MsgSendLog.today = function () {//点击上面状态筛选表格
    $("#startTime").val(setDateTime(new Date(),0) + " " + "00:00:00");
    $("#endTime").val(setDateTime(new Date(),0) + " " + "23:59:59");
    MsgSendLog.search();
};

$(function () {
    var defaultColunms = MsgSendLog.initColumn();
    var table = new BSTable(MsgSendLog.id, "/msgSendLog/list", defaultColunms);
    table.setPaginationType("server");
    table.setQueryParams(MsgSendLog.formParams());
    MsgSendLog.table = table.init();
    MsgSendLog.today();
    $(document).on('click','#laydate_clear,#laydate_today,#laydate_ok',function () {MsgSendLog.search();});
    checkDate = function () {MsgSendLog.search();};
});